package com.sczmgk.hotline_pzh.photo.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.sczmgk.hotline_pzh.utils.Tools;

/**
 * 相册实体
 * @author bo
 *
 */
public class PhotoAlbum implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 相册名字
	 */
	private String name;   //相册名字
	/**
	 * 图片的数量
	 */
	private String count; //数量
	/**
	 * 相册的第一张图片的索引
	 */
	private int  bitmap;  
	
	/**
	 * 图片实体的集合
	 */
	private List<PhotoItem> bitList = new ArrayList<PhotoItem>();
	
	public PhotoAlbum() {
	}
	
	/**
	 * 相册构造方法 
	 * @param name  名字
	 * @param count 图片数量
	 * @param bitmap 图片在相册内的索引
	 */
	public PhotoAlbum(String name, String count, int bitmap) {
		super();
		this.name = name;
		this.count = count;
		this.bitmap = bitmap;
	}


	@Override
	public boolean equals(Object o) {
		if(o instanceof PhotoAlbum){
			PhotoAlbum photoAlbum = (PhotoAlbum) o;
			
			if(Tools.equals(photoAlbum.name, name) && Tools.equals(photoAlbum.bitmap , bitmap)){
				return true;
			}
		}
		return false;
	}

	public List<PhotoItem> getBitList() {
		return bitList;
	}

	public void setBitList(List<PhotoItem> bitList) {
		this.bitList = bitList;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	public String getCount() {
		return count;
	}
	public void setCount(String count) {
		this.count = count;
	}
	public int getBitmap() {
		return bitmap;
	}
	public void setBitmap(int bitmap) {
		this.bitmap = bitmap;
	}
	/**
	 * 获取当前相册被选中的图片
	 * @return
	 */
	public List<String> getSelectPhotoList(){
		List<String> photoPathList = new ArrayList<String>();
		if(bitList!=null){
			for(int i=0;i<bitList.size();i++){
				PhotoItem photoItem = bitList.get(i);
				if(photoItem.isSelect()){
					photoPathList.add(photoItem.getPhotoPath());
				}
			}
		}
		return photoPathList;
	}
	
	/**
	 * 取得选择的相册图片的数量
	 * @return
	 */
	public int getSelectPhotoCount(){
		int count = 0;
		if(bitList!=null){
			for(int i=0;i<bitList.size();i++){
				PhotoItem photoItem = bitList.get(i);
				if(photoItem.isSelect()){
					count++;
				}
			}
		}
		return count;
	}
	

	@Override
	public String toString() {
		return "PhotoAibum [name=" + name + ", count=" + count + ", bitmap="
				+ bitmap + ", bitList=" + bitList + "]";
	}
}
